/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Beans;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
 *
 * @author user
 */
public class Database {
public Connection con=null;
public boolean isOK = true;
    public Database() {
        isOK=true;
        try {
            Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
        } catch (ClassNotFoundException ex) {
            System.out.println("Cannot load driver.");
            ex.printStackTrace();
            isOK=false;
        }
        
        String url = "jdbc:sqlserver://localhost:1433;databaseName=UserDB";
        try {
            //Try to save information into DB
            con = DriverManager.getConnection(url, "sa", "123456");
        } catch (SQLException ex) {
            System.out.println("Cannot connect to Database");
            System.out.println(ex.getMessage());
            ex.printStackTrace();
            isOK=false;
        }

    }
}
